package xiaohu.ODImportant;

import java.util.Scanner;

public class Main3 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String str = scanner.nextLine();
            String substring = str.substring(2);
            int count = 0;
            for (int i = 0; i < substring.length(); i++) {
                int temp = 0;
                switch (substring.charAt(i)) {
                    case 'A':
                        temp=10;
                        break;
                    case 'B':
                        temp=11;
                        break;
                    case 'C':
                        temp=12;
                        break;
                    case 'D':
                        temp=13;
                        break;
                    case 'E':
                        temp=14;
                        break;
                    case 'F':
                        temp=15;
                }
                if (temp == 0) {
                    temp = substring.charAt(i) - '0';
                }
                count = count * 16 + temp;

            }
            System.out.println(count);
        }
    }
}
